const app = getApp ();
// import uploadFile from "../../../utils/upload.js";
import {joinTeamApi} from '../../api/app';
Page ({
  /**
   * 页面的初始数据
   */
  data: {
    code: '',
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {},
  // 提交
  async submit () {
    try {
      const res = await joinTeamApi ({
        code: this.data.code,
        uid: wx.getStorageSync ('openId'),
      });
      if (res.code == 200) {
        wx.showToast ({
          title: '加入成功！',
          icon: 'none',
        });
        setTimeout (() => {
          wx.switchTab ({
            url: `/pages/agency/index`,
          });
        }, 1500);
      }else {
        wx.showToast ({
          title: res.msg,
          icon: 'none',
        });
      }
    } catch (error) {
      console.log (error);
    }
  },
});
